<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text">
<input type="button" value="添加文本" onclick="f1()">
<input type="button" value="添加图片" onclick="f2()">
<script>
  //得到页面中的文本框
  let i = document.querySelector("input");
  function f1() {
    //创建h1标签
    let h = document.createElement("h1");
    //把文本框的内容赋值给h1
    h.innerText = i.value;
    //把h1添加到页面中
    document.body.append(h);
  }
  function f2() {
      //创建图片标签
      let img = document.createElement("img");
      img.src = "../b.jpg";
      document.body.append(img);
  }
</script>
</body>
</html>